package com.ereport.dao;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;

import com.ereport.entity.AdminExeBudget;
import com.ereport.util.ApplicationContext;

public class MyBudgetDAO {
static Transaction tx;
	
	private  void endOperations(Session session) {
		
		session.close();
		session=null;
	}

	private  Session startOperations()throws Exception {
		
		Session session = ApplicationContext.getHiberSession().openSession();
		tx=session.beginTransaction();
		return session;
		
	}

	public List<AdminExeBudget> getMyBudget(int id, String fyear) throws Exception {
		List<AdminExeBudget> aeb=new ArrayList<AdminExeBudget>();
		Session session=startOperations();
		Query qry=session.createQuery("from AdminExeBudget where exe_id=:id and fyear=:fyear");
		qry.setInteger("id", id);
		qry.setString("fyear",fyear);
		aeb=qry.list();
		endOperations(session);
		return aeb;
	}
	
}
